<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib  prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="redis" uri="http://www.shopjsp.com/redisTag/functions" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<c:set var="basePath" value="${redis:getSysConfig('base_path_back')}"/>
<c:set var="srcPath" value="${redis:getSysConfig('sysFileVisitRoot_back')}"/>
<c:set var="uploadPath" value="${redis:getSysConfig('uploadFileVisitRoot')}"/>
<script type="text/javascript">
    /**
     * 自定义验证规则
     */
    function validateForm(){
        form.bootstrapValidator({
            message: "无效的值",
            feedbackIcons: {
                valid: "glyphicon glyphicon-ok",
                invalid: "glyphicon glyphicon-remove",
                validating: "glyphicon glyphicon-refresh"
            },
            fields: {
                sort: {
                    validators: {
                        notEmpty: {message: "排序不可为空"},
                        stringLength: {max: 4,message: "排序最大长度为4"},
                        numeric: {
                            message: '只能输入数字'
                        }
                    }
                }
            }
        });
    }

    /**
     * 编辑每日推荐商品
     */
	<shiro:hasPermission name="back_gotoDayRecommendPage_update">
    function editInfo(){
        /**获取选中行的id**/
        var selectedRow= $("#tt").bootstrapTable('getSelections');
        if(selectedRow.length==1){
            var id=selectedRow[0].id;
            $("#btn_edit").attr("data-target","#editModal");/**选中了记录后才可打开对应的模态框**/
            $.ajax({
                type: "POST",
                dataType: "JSON",
                url: "${basePath}/back/dayRecommend/getDayRecommendInfo.sjson",
                data: {id:id},
                success: function(result){
                    var data = JSON.parse(result.data);
                    /**隐藏域**/
                    $("#id").val(data.id);
                    $("#productId").val(data.productId);
                    /**可见表单控件**/
                    $("#photo").html("<img id='uploadImg_detail_"+id+"' class='uploadImg' onMouseOver='showDetailBigImage("+id+",3,3,0)'  onMouseOut='showDetailRebackImage("+id+",1,1)' src='${uploadPath}/"+data.logoImages+"' onerror='this.src=\"${srcPath}/common/images/mrbj.png\"' width='50px' height='50px' />");
                    $("#productName").html(data.productName);
                    $("#productCode").html(data.productCode);
                    $("#sort").val(data.sort);
                    $("#isShow_"+data.isShow).attr("checked",true);
                }
            });
        }else{
            $("#btn_edit").attr("data-target", "");/**没有选中记录不可打开模态框**/
            showMsg("请选择一行记录！");
        }
    }
    </shiro:hasPermission>
</script>

<!--添加编辑模态框（Modal） -->
<div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static">
	<div class="modal-dialog" style="width:70%">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
				<h5 class="modal-title" id="myModalLabel">编辑每日推荐商品</h5>
			</div>
			<div class="modal-body">
				<form id="form1"  method="post" action="${basePath}/back/dayRecommend/saveOrUpdateDayRecommend.sjson">
					<input id="id" type="hidden" name="id" noclear="true"/>
					<input id="productId" type="hidden" name="productId" noclear="true"/>

					<table align="center" class="addOrEditTable table-bordered table" style="width:100%;">
						<tr>
							<td class="toright_td" width="150px">商品图片:</td>
							<td class="toleft_td" colspan="3">&nbsp;&nbsp;<span id="photo"></span></td>
						</tr>
						<tr>
							<td class="toright_td" width="150px">商品名称:</td>
							<td class="toleft_td" colspan="3">&nbsp;&nbsp;<span id="productName"></span></td>
						</tr>
						<tr>
							<td class="toright_td" width="150px">商品编号:</td>
							<td class="toleft_td" colspan="3">&nbsp;&nbsp;<span id="productCode"></span></td>
						</tr>
						<tr>
							<td class="toright_td" width="140px"><span style="color:red">* </span>排序:&nbsp;&nbsp;</td>
							<td  class="toleft_td">
								<div class="form-group">
									<input type="text" class="form-control input-sm" id="sort" name="sort" placeholder="请输入排序"/>
								</div>
							</td>
						</tr>
						<tr>
							<td class="toright_td" width="140px"><span style="color:red">* </span>是否显示:&nbsp;&nbsp;</td>
							<td  class="toleft_td">
								<label class="checkbox-inline">
									<input type="radio" name="isShow" id="isShow_1" class="radioInput" value="1" checked="checked">&nbsp;&nbsp;已显示
								</label>
								<label class="checkbox-inline">
									<input type="radio" name="isShow" id="isShow_0" class="radioInput" value="0">未显示
								</label>
							</td>
						</tr>
					</table>
				</form>
			</div>
			<div class="modal-footer">
				<button type="button" id="validateBtn" class="btn btn-primary"  onclick="submitForm()">保存</button>
				<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
			</div>
		</div><!-- /.modal-content -->
	</div><!-- /.modal -->
</div>